<%@ page import="java.util.Map" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>用户登录</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background-color: #f5f5f5;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }

        .login-container {
            background-color: white;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            width: 350px;
            text-align: center;
        }

        h2 {
            color: #333;
            margin-bottom: 24px;
        }

        .form-group {
            margin-bottom: 20px;
            text-align: left;
        }

        label {
            display: block;
            margin-bottom: 6px;
            font-weight: 500;
            color: #555;
        }

        input[type="text"],
        input[type="password"] {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
            font-size: 14px;
        }

        input[type="submit"] {
            width: 100%;
            padding: 12px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s;
        }

        input[type="submit"]:hover {
            background-color: #45a049;
        }

        .error-message {
            color: #d32f2f;
            margin-top: 15px;
            padding: 10px;
            background-color: #fde0e0;
            border-radius: 4px;
            font-size: 14px;
        }

        .footer {
            margin-top: 20px;
            font-size: 13px;
            color: #777;
        }

        /* 新增记住我选项样式 */
        .remember-me {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
        }

        .remember-me input[type="checkbox"] {
            margin-right: 8px;
            width: auto;
        }

        .remember-me label {
            margin-bottom: 0;
            font-weight: normal;
            color: #555;
        }
        .success-message {
            color: #388e3c;
            margin-top: 15px;
            padding: 10px;
            background-color: #e8f5e9;
            border-radius: 4px;
            font-size: 14px;
        }
    </style>
</head>
<body>
<div class="login-container">
    <h2>用户登录</h2>

    <!-- 显示网站统计信息 -->
    <!-- 显示网站统计信息 -->
    <div class="site-stats">
        总访问量: <%= application.getAttribute("totalVisits") != null ? application.getAttribute("totalVisits") : 0 %> |
        当前在线: <%= application.getAttribute("currentUsers") != null ? application.getAttribute("currentUsers") : 0 %> |
        注册用户: <%= ((Map<String,String>)application.getAttribute("userDatabase")) != null ?
            ((Map<String,String>)application.getAttribute("userDatabase")).size() : 0 %>
    </div>

    <form action="checkLogin.jsp" method="post">
        <div class="form-group">
            <label for="username">用户名</label>
            <input type="text" id="username" name="username" placeholder="请输入用户名" required>
        </div>
        <div class="form-group">
            <label for="password">密码</label>
            <input type="password" id="password" name="password" placeholder="请输入密码" required>
        </div>

        <div class="remember-me">
            <input type="checkbox" id="remember" name="remember">
            <label for="remember">记住我</label>
        </div>

        <input type="submit" value="登录">
    </form>

    <%-- 错误消息显示 --%>
    <%
        String errorMsg = (String)request.getAttribute("errorMsg");
        if(errorMsg != null) {
            out.print("<div class='error-message'>" + errorMsg + "</div>");
        }

        // 注册成功消息
        String successMsg = (String)request.getAttribute("msg");
        if(successMsg != null) {
            out.print("<div class='success-message'>" + successMsg + "</div>");
        }
    %>

    <div class="footer">
        还没有账号? <a href="register.jsp">立即注册</a>
    </div>
</div>
</body>
</html>